package com.codeZ.CompositePattern.example;

/**
 * 叶子结点
 *
 * @author codeZhang
 * @Date 2024/8/15 10:42
 */
public class Leaf extends Component{
    @Override
    public void add(Component component) {
        System.err.println("Cannot add to a leaf.");
    }

    @Override
    public void remove(Component component) {
        System.err.println("Cannot remove from a leaf.");
    }

    @Override
    public Component getChild(int index) {
        return new Leaf();
    }

}
